package com.zx._03_并发.chapter_04_public;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import lombok.extern.slf4j.Slf4j;

/**
 * 不可变对象——guava（google提供的方法）
 */
@Slf4j
public class Demo_04_final2 {

    private static ImmutableMap<Integer, Integer> map = ImmutableMap.of(1, 1, 2, 2, 3, 3, 4, 4, 5, 5);
    private static ImmutableList<Integer> list = ImmutableList.of(1, 2, 3, 4, 5, 6, 7);
    private static ImmutableSet<Integer> set = ImmutableSet.of(1, 2, 3, 4, 5);

    public static void main(String[] args) {
        map.put(4, 4);//抛出异常java.lang.UnsupportedOperationException
        log.info("新增元素={}", map.toString());
        map.put(1, 2);//抛出异常java.lang.UnsupportedOperationException
        log.info("修改元素={}", map.toString());
    }
}
